#
FROM php:7.2.3-fpm

RUN set -xe \
    && apt-get update

# 复制文件
COPY config/php.ini /usr/local/etc/php/
COPY config/docker.conf /usr/local/etc/php-fpm.d/
COPY config/www.conf /usr/local/etc/php-fpm.d/
COPY run.sh /tmp/run.sh

#安装库和PHP扩展
RUN apt-get install -y \
        zlib1g-dev wget\
        libfreetype6-dev \
        libmcrypt-dev \
        libjpeg62-turbo-dev \
        libxml2-dev \
        libxslt1.1 libxslt1-dev \
        git \
        librabbitmq-dev \
		libssh-dev \
    && rm -rf /var/lib/apt/lists/* \
    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
    && docker-php-ext-install -j$(nproc) pdo_mysql mbstring bcmath  pcntl shmop gd soap sockets zip opcache xsl

RUN pecl channel-update pecl.php.net \
	&& pecl install igbinary redis mcrypt amqp swoole \
    && docker-php-ext-enable igbinary redis opcache amqp swoole

RUN mkdir /var/log/php/  \
    && chmod -R 666 /var/log/php/ \
    && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

# 设置权限
RUN chmod +x /tmp/run.sh

# 安装xdebug
RUN wget http://pecl.php.net/get/xdebug-2.6.0.tgz \
	&& tar -vxf xdebug-2.6.0.tgz \
	&& cd ./xdebug-2.6.0 \
	&& phpize \
	&& ./configure \
	&& make \
	&& make install \
	&& docker-php-ext-enable xdebug

RUN pecl install protobuf
RUN docker-php-ext-enable protobuf
# 复制xdebug配置文件
COPY config/xdebug.ini /usr/local/etc/php/conf.d/

# 运行
CMD ["/bin/bash","/tmp/run.sh"]
